extends "../i_horse5_Hide/i_horse5_Hide.gd"
var flag 
func init():
    .init()
    name = "纯血战马"
    resetdata()
    info = "警戒：高度警惕，每秒对周围一格敌人添加1层<畏缩>；若被攻击[除特效伤害]，10%减免50%物理伤害，\n10%反弹50%伤害，10%使伤害固定为生命上限1%[前提:大于1%][cd:2秒]\n" + info

func _connect():
    ._connect()
    masCha.connect("onHurt",self,"jj")
    masCha.connect("onBattleStart",self,"resetflag")

func resetflag():
    flag = 1

func jj(atkinfo):
    if atkinfo.isMiss || atkinfo.atkType == Chara.AtkType.EFF || !flag:return
    if sys.rndPer(10) && atkinfo.hurtType == Chara.HurtType.PHY:
        flag =  0
        atkinfo.hurtVal *= 0.5
        return
    if sys.rndPer(10):
        flag = 0
        atkinfo.hurtVal *= 0.5
        masCha.hurtChara(atkinfo.atkCha,atkinfo.hurtVal,atkinfo.hurtType,Chara.AtkType.EFF)
        return
    if sys.rndPer(10) && atkinfo.hurtVal > masCha.att.maxHp * 0.01:
        flag = 0
        atkinfo.hurtVal = masCha.att.maxHp * 0.01
        return

func _upS():
    ._upS()
    if !flag:
        cnt3 += 1
        if cnt3 == 2:
            cnt3 = 0
            flag = 1
    var v = [Vector2(-1,1),Vector2(0,1),Vector2(1,1),Vector2(-1,0),Vector2(1,0),Vector2(-1,-1),Vector2(0,-1),Vector2(1,-1)]
    for i in v:
        var tmp = sys.main.matCha(masCha.cell + i)
        if tmp && tmp.get("team") != masCha.team:
            tmp.addBuff(ctrl.b_weisuo.new(1))
